<?php
use yii\helpers\Url;
use yii\Web\View;
use app\assets\PmpListAsset;
PmpListAsset::register($this);
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  \Yii::t('pmp', 'PMP List'),
  \Yii::t('common', 'Data')
];
$jsMsgs = $this->context->loadJsMsgs([
  'table',
  'pmpList'
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="page-header">
  <h1>
    <?=\Yii::t('pmp', 'PMP List')?>
    <small><?=\Yii::t('common', 'Data')?></small>
  </h1>
</div>
<div class="panel panel-default">
  <div class="panel-heading"> 
    <i class="fa fa-table"></i>
    <?=\Yii::t('pmp', 'PMP List')?>
    <ul class="list-inline list-unstyled pull-right">
      <li>
        <button class="btn btn-xs btn-success" data-type="sync-pmp" id="Sync-latest-pmp">
          <i class="fa fa-refresh"></i>
          <?=\Yii::t('pmp', 'Sync latest PMP')?>
        </button>  
      </li>
      <li>
        <a class="data-table-refresh" href="#" title="<?=\Yii::t('common', 'Click to refresh data')?>">
          <i class="fa fa-refresh"></i>
        </a>
      </li>
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body">
    <div class="panel panel-dotted">
        <div id="list-loading-wrap" class="local-loading-wrap"></div>
        <div class="table-responsive">
          <table class="table table-hover table-striped table-bordered table-condensed" id="data-table" data-tag="vm-adserver.media-adspace-list">
            <thead class="heading">
              <tr>
                <th class="tab-text-le" data-resizable-column-id="id" data-search="on" data-filter="on">ID</th>
                <th class="tab-text-sm" data-resizable-column-id="name" data-search="on" data-filter="on"><?=\Yii::t('pmp', 'PMP Name')?></th>
                <th class="tab-text-sm" data-resizable-column-id="price" data-search="on" data-filter="on"><?=\Yii::t('pmp', 'PMP Price')?></th>
                <th class="tab-text-lg" data-resizable-column-id="resource" data-search="on" data-filter="on"><?=\Yii::t('pmp', 'Adspaces')?></th>
              </tr>
            </thead>
            <tbody>
              <tr role="row">
                <td class="text-center dataTables_empty" colspan="10"><?=\Yii::t('pmp', 'No Data')?></td>
              </tr>
            </tbody>
          </table>
        </div>
    </div>    
  </div>
</div>
<?php
  $url = Yii::getAlias('@web') . '/response/pmpList/pmpList.php';
  $syncListOp = Yii::getAlias('@web') . '/response/pmpList/syncOk.php';
  $url = Url::to(['get-pmp-list']);
  $syncListOp = Url::to(['sync-pmp']);
  $this->registerJs("VAM.setVar('PMP_DATA_LIST', '$url')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('SYNC_LIST_OP', '$syncListOp')", View::POS_HEAD);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/pmpList/pmpList.js"]);
  });
</script>
